package me.work.pay.jsyl.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import me.work.pay.jsyl.R;
import me.work.pay.jsyl.mvp.contract.GroupListContract;
import me.work.pay.jsyl.mvp.contract.OrderListContract;
import me.work.pay.jsyl.mvp.model.OrderListModel;
import me.work.pay.jsyl.mvp.model.entity.OrderNormalData;
import me.work.pay.jsyl.mvp.ui.holder.AutoBaseViewHolder;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 09/14/2020 08:45
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@Module
public abstract class OrderListModule {

    @Binds
    abstract OrderListContract.Model bindOrderListModel(OrderListModel model);

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(GroupListContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<OrderNormalData> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    @Named("port")
    static BaseQuickAdapter<OrderNormalData, AutoBaseViewHolder> provideAdapter(List<OrderNormalData> lists) {
        return new BaseQuickAdapter<OrderNormalData, AutoBaseViewHolder>(R.layout.team_item, lists) {

            @Override
            protected void convert(AutoBaseViewHolder helper, OrderNormalData item) {
                helper.setText(R.id.tv1, item.timeEnd);
                helper.setText(R.id.tv2, item.totalNormal);
                ImageView iv=helper.getView(R.id.iv);
                switch (item.orderType){
                    case "微信":
                        iv.setImageResource(R.drawable.wx_img);
                        break;
                    case "支付宝":
                        iv.setImageResource(R.drawable.zfb_img);
                        break;
                    default://云闪付
                        iv.setImageResource(R.drawable.ysf_img);
                        break;
                }
            }
        };
    }
    @ActivityScope
    @Provides
    @Named("land")
    static BaseQuickAdapter<OrderNormalData, AutoBaseViewHolder> provideAdapter2(List<OrderNormalData> lists) {
        return new BaseQuickAdapter<OrderNormalData, AutoBaseViewHolder>(R.layout.team_item_land, lists) {

            @Override
            protected void convert(AutoBaseViewHolder helper, OrderNormalData item) {
                helper.setText(R.id.tv1, item.timeEnd);
                helper.setText(R.id.tv2, item.totalNormal);
                ImageView iv=helper.getView(R.id.iv);
                switch (item.orderType){
                    case "微信":
                        iv.setImageResource(R.drawable.wx_img);
                        break;
                    case "支付宝":
                        iv.setImageResource(R.drawable.zfb_img);
                        break;
                    default://云闪付
                        iv.setImageResource(R.drawable.ysf_img);
                        break;
                }
            }
        };
    }
}